招生考试网
学历| 高考 美术高考 考研 自考 成考 专升本 中考 会考 外语| 四六级 职称英语 商务英语 公共英语 日语能力 翻译资格 JTEST
资格| 公务员 报关员 银行从业 司法 导游 教师资格 报关 财会| 会计证 经济师 会计职称 注册会计 税务师 资产评估 审计师
工程| 一建 二建 造价师 造价员 咨询师 监理师 安全师 医学| 卫生资格 执业医师 执业药师 执业护士 | 教案 论文 文档
IT类| 计算机等级 计算机软考 职称计算机 高校计算机 推荐-国家公务员 事业单位招聘 军校国防生 自主招生 艺术特长生 招飞
 3773考试网 - 计算机等级考试 - 高校计算机 - 正文

DELPHI8操作符重载的例子

来源:fjzsksw.com 2009-11-3 17:47:47

unit WinForm;
  interface
  uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data;
  type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION \'Designer Managed Code\'}
  strict private
  /// <summary>
  /// Required designer variable.
  /// </summary>
  Components: System.ComponentModel.Container;
  Button1: System.Windows.Forms.Button;
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  procedure InitializeComponent;
  procedure Button1_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  procedure Dispose(Disposing: Boolean); override;
  private
  { Private Declarations }
  public
  constructor Create;
  end;
  //写成类也可以,这里我用了记录。由于记录是值类型省去了创建实例的麻烦
  TClassTest=record
  public
  FA:Integer;
  //重载了“+”操作符
  class operator add(A,B:TClassTest):TClassTest;
  end;
  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
  implementation
  {$REGION \'Windows Form Designer generated code\'}
  /// <summary>
  /// Required method for Designer support -- do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  procedure TWinForm.InitializeComponent;
  begin
  Self.Button1 := System.Windows.Forms.Button.Create;
  Self.SuspendLayout;
  //
  // Button1
  //
  Self.Button1.Location := System.Drawing.Point.Create(96, 88);
  Self.Button1.Name := \'Button1\';
  Self.Button1.Size := System.Drawing.Size.Create(392, 112);
  Self.Button1.TabIndex := 0;
  Self.Button1.Text := \'Button1\';
  Include(Self.Button1.Click, Self.Button1_Click);
  //
  // TWinForm
  //



  • 上一个文章:
  • 网站版权与免责声明
    ①由于各方面情况的不断调整与变化,本网所提供的相关信息请以权威部门公布的正式信息为准.
    ②本网转载的文/图等稿件出于非商业性目的,如转载稿涉及版权及个人隐私等问题,请在两周内邮件fjksw@163.com联系.
    最新文章


    | 关于我们 | 联系我们 | 版权申明 | 网站导航 |
    琼ICP备12003406号